#/bin/bash

cd /root

groupadd -g 1000 HwHiAiUser
useradd -g HwHiAiUser -u 1000 -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash

sudo yum install -y gcc 
sudo yum install -y gcc-c++ 
sudo yum install -y make 
sudo yum install -y cmake 
sudo yum install -y unzip 
sudo yum install -y zlib-devel 
sudo yum install -y libffi-devel 
sudo yum install -y openssl-devel 
sudo yum install -y pciutils 
sudo yum install -y net-tools 
sudo yum install -y sqlite-devel 
sudo yum install -y lapack-devel 
sudo yum install -y gcc-gfortran 
sudo yum install -y python3-devel

#export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
#export PATH=/usr/local/python3.7.5/bin:$PATH

#mkdir ~/.pip
#cat <<EOF >  ~/.pip/pip.conf
#[global]
#index-url = https://pypi.tuna.tsinghua.edu.cn/simple
#[install]
#trusted-host = https://pypi.tuna.tsinghua.edu.cn
#EOF





#wget https://repo.huaweicloud.com/python/3.7.5/Python-3.7.5.tgz

wget https://repo.huaweicloud.com/python/3.7.5/Python-3.7.5.tgz --no-check-certificate
tar -zxvf Python-3.7.5.tgz
cd Python-3.7.5
./configure --prefix=/usr/local/python3.7.5 --enable-loadable-sqlite-extensions --enable-shared
make -j120
make install


export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/python3.7.5/bin:$PATH

cd .. 


mkdir ~/.pip
cat <<EOF >  ~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
EOF


pip3 install --upgrade pip
pip3 install attrs
pip3 install cython
pip3 install numpy
pip3 install decorator
pip3 install sympy
pip3 install cffi
pip3 install pyyaml
pip3 install pathlib2
pip3 install psutil
pip3 install protobuf
pip3 install scipy
pip3 install requests
pip3 install absl-py

wget https://repo.huaweicloud.com/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar -zxvf gcc-7.3.0.tar.gz
cd gcc-7.3.0
./contrib/download_prerequisites
#wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
#wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
#wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
#wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
#./contrib/download_prerequisites
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/gcc7.3.0
make -j$(grep -w processor /proc/cpuinfo|wc -l)    # 通过grep -w processor /proc/cpuinfo|wc -l查看cpu数，示例为15，用户可自行设置相应参数。
make install    


export LD_LIBRARY_PATH=/usr/local/gcc7.3.0/lib64:${LD_LIBRARY_PATH}
export CC=/usr/local/gcc7.3.0/bin/gcc
export CXX=/usr/local/gcc7.3.0/bin/g++
export PATH=/usr/local/gcc7.3.0/bin:${PATH}

